<%@page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="web" uri="http://meerkat.qunar.com/web"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<web:designCss/>
<%@include file="/WEB-INF/include/head.jsp" %>
</head>
<body>
    <div class="wrapper">
        <web:titleBar title="添加用户" />

        <div class="main content">
        <form id="userAddForm" >
            <table>
                <tr>
                    <td>账号类型</td>
                        <td>
                            <input type="radio" id="authType_sso" name="authType" value="0" checked onclick="$('#pwdWarp').hide()" />&nbsp;<label for="authType_sso">SSO用户</label>&nbsp;&nbsp;
                            <input type="radio" id="authType_local" name="authType" value="1" onclick="$('#pwdWarp').show()" />&nbsp;<label for="authType_local">密码用户</label>
                        </td>
                    </tr>
                    <tr>
                        <td>用户名</td>
                        <td><input type="text" id="name" name="name" value="" /></td>
                    </tr>
                    <tr>
                        <td>姓名</td>
                        <td><input type="text" id="realname" name="realname" value="" /></td>
                    </tr>
                    <tr id="pwdWarp" style="display:none;">
                        <td>密码</td>
                        <td><input type="password" id="password" name="password" value="" /></td>
                    </tr>
                    <tr>
                        <td>所属部门</td>
                        <td><input type="text" id="department" name="department" value="" /></td>
                    </tr>
                    <tr>
                        <td>邮箱</td>
                        <td><input type="text" id="email" name="email" value="" /></td>
                    </tr>
                    <tr>
                        <td>用户组</td>
                        <td>
                            <select class="sel_mult" name="gid" id="gid">
                                <c:forEach items="${groupList}" var="group">
                                    <option value="${group.id}">${group.name}</option>
                                </c:forEach>
                            </select>
                        </td>
                    </tr>
            </table>
            <input type="button" id="submit" class="button button-blue" value="提交" />
        </form>
        </div>
    </div>

    <script type="text/javascript">
        $(document).ready(function(){

            $('#submit').click(function() {
                if($('#authType_local').attr("checked") == "checked"
                    && $('#password').val() == '') {
                    Qadmin.FW.Dialog.alert({msg : '添加密码用户，密码不能为空!'});
                    return false;
                }
                return Qadmin.FW.Ajax.post({
                    url: QG_CONFIG.PATH + 'user/add.htm',
                    formId: "userAddForm"
                }, function(xhr){
                    Qadmin.FW.Url.goToUrl(QG_CONFIG.PATH + 'user/list.htm');
                });
            });
        });
    </script>
</body>
</html>
